package src;

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;

public class ResourceLoader {
	
	private static ResourceLoader rl = new ResourceLoader();
	
	public static Image getImage(String path){
		return Toolkit.getDefaultToolkit().getImage(rl.getClass().getResource("/resources/" + path));
	}
	
	public BufferedImage getSprite(int x, int y, int width, int height, BufferedImage spriteSheet){
		BufferedImage sprite = spriteSheet.getSubimage(x, y, width, height);
		return sprite;
	}
	
	public BufferedImage loadImage(String path) throws IOException{
		URL url = this.getClass().getResource("/resources/" + path);
		BufferedImage img = ImageIO.read(url);
		return img;
	}
}
